#检查程序是否在运行
is_exist(){
 appName="$1"
 id=`ps -ef|grep '$APP_NAME'|grep -v grep|awk '{print $2}' `
 #如果不存在返回0，存在返回0 
 if [ -z "${pid}" ]; then
 return ${pid}
 else
 return 0
 fi
}
killPross(){
	pid_name="$1"
	echo "杀死的进程名称：" $pid_name
	 
	pid=$(ps -ef|grep $pid_name|grep -v grep|awk '{print $2}')
	 
	echo "pid列表：" $pid
	 
	for item in $pid
	do
	  echo "杀死进程pid=" $item
	  kill -9 $item
	done
}
run_restart_server(){
 appName="$1"
 appSourcePath="$2"
 appRunPath="/home/bcm/${appName#*-}"

if [ ! -d "$appRunPath" ]; then
    echo "创建文件夹 $appRunPath"
    mkdir -p $appRunPath
else
    echo "$appRunPath 文件夹已存在"
fi

\cp -rb $appSourcePath $appRunPath

killPross $appName
#nohup java -Dfile.encoding=utf-8  -jar $appRunPath/$appName.jar > $appRunPath/log.out 2>&1 &
nohup java -Dfile.encoding=utf-8  -jar $appRunPath/$appName.jar > /dev/null 2> /dev/null &

}

run_restart_server xpp-gateway ./xpp-gateway/target/xpp-gateway.jar
run_restart_server xpp-auth ./xpp-auth/target/xpp-auth.jar
#run_restart_server xpp-visual-monitor ./xpp-visual/xpp-monitor/target/xpp-visual-monitor.jar
run_restart_server xpp-modules-system ./xpp-modules/xpp-system/target/xpp-modules-system.jar
#run_restart_server xpp-modules-file ./xpp-modules/xpp-file/target/xpp-modules-file.jar
run_restart_server xpp-modules-job  ./xpp-modules/xpp-job/target/xpp-modules-job.jar
run_restart_server xpp-marketdata   ./xpp-modules/xpp-marketdata/target/xpp-marketdata.jar
run_restart_server xpp-pricing    ./xpp-modules/xpp-pricing/target/xpp-pricing.jar







